import { Item_base } from "./Item_base";
import Node from "./Node";
import Sprite from "./Sprite";
export enum fontMap{
    defautl = 'ttf_cn.ttf'
}
export default class Lable implements Item_base{
    uuid: string = '1';
    name: string = 'Sprite';
    display: boolean = true;
    x: number = 0;
    y: number = 0;
    _x: number = 0;
    _y: number = 0;
    canvans: Node;
    child: any[] = []
    parent: any = undefined;


    string:string = 'none';
    color:string = '#000000';
    fontSize:number = 22;
    font:string = 'ttf_cn.ttf';
    constructor(canvans:Node){
        this.canvans = canvans;
    }
    addSprite(): Sprite {
        let item = new Sprite(this.canvans);
        item.parent = this;
        this.child.push(item);
        return item;
    }
    addLable() {
        let item = new Lable(this.canvans);
        item.parent = this;
        this.child.push(item);
        return item;
    }
    setFont(k:fontMap){
        this.font = k;
    }


    draw(){
        this._x = this.x;
        this._y = this.y;
        let offsetX = 0;
        let offsetY = 0;
        if(this.parent){
            offsetX = this.parent._x;
            offsetY = this.parent._y;
        }
        this.canvans.render(offsetX,offsetY,[this]);
    }
}